package com.chen.webuser.controller;

import com.chen.util.Check;
import com.chen.util.Result;
import com.chen.util.ResultCode;
import com.chen.webuser.entity.Dynamic;
import com.chen.webuser.service.DynamicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 动态相关接口
 */
@RestController
@RequestMapping("/dynamic")
public class DynamicController {
    @Autowired
    private DynamicService dynamicService;
    /**
     * 保存动态
     */
    @PostMapping("/save")
    public Result save(@RequestBody Dynamic dynamic) {
        Check.checkParameter(dynamic);
        dynamicService.saveDynamic(dynamic);
        return Result.build(null, ResultCode.SUCCESS);
    }


    /**
     * 获取动态列表
     */
    @GetMapping("/list")
    public Result listDynamic() {
        List<Dynamic> dynamic=dynamicService.listDynamic();
        return Result.build(dynamic, ResultCode.SUCCESS);
    }
}
